package com.pt25.base.model.security;


import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;


/**
 * 目前此拦截器的功能是将SessionData保存到ThreadLocal上下文中和将SessionData从ThreadLocal上下文中删除
 * SecurityInterceptor - >
 * LoginCheckAspect -> PermissionCheckAspect/RoleCheckAspect ->
 * SecurityInterceptor
 */
class SecurityInterceptor implements HandlerInterceptor {
    /**
     * 清理用户上下文回话数据
     */
    @Override
    public void afterCompletion(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler, @Nullable Exception ex) throws Exception {
        SecurityThreadLocal.clean();
    }
}
